<?php
//微信配置

namespace App\Services\Wx;

//use EasyWeChat\Factory;
use EasyWeChat\MiniApp\Application;

class WxConfig
{

    public static $appId = 'wx9284fada105c64b7';

    public static $secret = '0e7a2277f039e148693229280464d1f4';

    public static $secretKeyV3 = 'Zhonghuashehuijiuzhujijinhui2009';

    //    public static $mchId = 1619145919; //商户号
    public static $mchId = 1580043601; //商户号

    //    public static $couponCallbackUrl = 'https://wangyizhe.gbd-coupon.lingxi.ren/wx/coupon/userconsumecallback'; //todo: 上显示切换线上域名
    public static $couponCallbackUrl = 'https://api-gbd-coupon.lxi.cloud/wx/coupon/userconsumecallback'; //todo: 此为线上域名

    //过期通知模版id
    public static $expireTemplateId = '84U6QieuqURAKiRLgBBFnCr6DCBRtGzM37j_2YLOCSI';

    //政务用户凭证机构表示id
    public static $userCertInstitutionId = '1580043601';

    //政务用户凭证特殊人群类型
    public static $userCertSpecialType = 'SOCIAL_WORKER';


    /**
     * 获取微信token
     * @return mixed|string
     */
    public static function getToken()
    {
        $config = [
            'app_id'  => env('APPID'),
            'secret'  => env('APP_SECRET'),
            'token'   => 'easywechat',
            'aes_key' => '......',

            /**
             * 接口请求相关配置，超时时间等，具体可用参数请参考：
             * https://github.com/symfony/symfony/blob/5.3/src/Symfony/Contracts/HttpClient/HttpClientInterface.php
             */
            'http'    => [
                'throw'   => false, // 状态码非 200、300 时是否抛出异常，默认为开启
                'timeout' => 5.0,
                'retry'   => true, // 使用默认重试配置
            ],
        ];

        $app = new Application($config);
        $api = $app->getAccessToken();
        $token = $api->getToken();

        return $token;
    }


}
